<?php

require_once( "db.inc" );

define( "NM_TIMEZONE", "America/Chicago" );
define( "NM_SQL_DATE_FORMAT", "Y-m-d H:i:s" );

$NMZoneUtc = new DateTimeZone( "UTC" );
$NMZoneLocal = new DateTimeZone( NM_TIMEZONE );

class NMHtmlItem
{
	private $_tag;
	private $_attributes;
	private $_content;
	
	function __construct( $tag, $content = "" )
	{
		$this->_tag = $tag;
		$this->_content = $content;
	}
	
	function AddAttribute( $attr, $value )
	{
		$this->_attributes[ $attr ] = $value;
	}
	
	function Format()
	{
		$html = "<$this->_tag";
		if ( isset( $this->_attributes ) )
		{
			foreach ( $this->_attributes as $attr => $value )
			{
				$html .= " $attr=\"$value\"";
			}
		}
		if ( strlen( $this->_content ) == 0 )
			$html .= "/>\n";
		else
			$html .= ">$this->_content</$this->_tag>\n";
		return $html;
	}
	
	function Write()
	{
		echo $this->Format();
	}
}

function NMOpenDB()
{
	$link = mysql_connect( LOGGER_DB_HOST, LOGGER_DB_USER, LOGGER_DB_PASSWORD );
	if ( $link )
	{
		mysql_select_db( LOGGER_DB_NAME );
	}
	
	return $link;
}

?>
